package com.adou.d1;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.Statement;

/**
 * 快速入门
 */
public class JDBCDemo {
    public static void main(String[] args) throws Exception {
        // 1.注册驱动
        Class.forName("com.mysql.jdbc.Driver");

        String url = "jdbc:mysql://127.0.0.1/db1?useSSL=false";
        String username = "root";
        String password = "root";
        // 2.获取连接
        Connection conn = DriverManager.getConnection(url, username, password);

        // 3.sql
        String sql = "update account1 set money = 2000 where id = 1";

        // 4.获取执行sql对象
        Statement stmt = conn.createStatement();

        // 5.执行sql
        int result = stmt.executeUpdate(sql);// 受影响行数

        // 6.打印结果
        System.out.println(result);

        // 7.释放资源
        stmt.close();
        conn.close();
    }
}
